package com.jydw.da.frame.config.db;

import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;

import java.util.Collection;
import java.util.Properties;

/**
 * 我标准切分算法
 *
 * @author chenyj
 * @date 2023/06/26
 */
@Slf4j
public class MyStandardDBShardingAlgorithm implements StandardShardingAlgorithm<Long> {
    @Override
    public String doSharding(Collection<String> collection, PreciseShardingValue<Long> preciseShardingValue) {
        for (String aa : collection) { //所有库或表
            System.out.println("aa： " + aa);
            //执行逻辑，返回需要执行的库或表
        }
        //返回需要具体操作的库或表名
        return null;
    }

    @Override
    public Collection<String> doSharding(Collection<String> collection, RangeShardingValue<Long> rangeShardingValue) {
        return null;
    }

    @Override
    public Properties getProps() {
        System.out.println("123+getProps");
        return null;
    }

    @Override
    public void init(Properties properties) {
        System.out.println("123+init");
    }
}
